package com.masterclient.app.businessmodule.vipmodule.adapter;


import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.vipmodule.bean.Logistics;

/**
 * 物流adapter
 */
public class LogisticsAdapter extends BaseQuickAdapter<Logistics, BaseViewHolder> {


    public LogisticsAdapter() {
        super(R.layout.adapter_logistics);
    }

    @Override
    protected void convert(BaseViewHolder helper, Logistics item) {
        ImageView imageView = helper.getView(R.id.img_view);
        TextView line1 = helper.getView(R.id.line1);
        TextView line2 = helper.getView(R.id.line2);
        TextView item1 = helper.getView(R.id.item1_tv);
        TextView item2 = helper.getView(R.id.item2_tv);
        item2.setText(item.getContent());
        if (getItemCount() == 1) {
            item1.setVisibility(View.GONE);
            line1.setVisibility(View.GONE);
            line2.setVisibility(View.GONE);
        } else {
            if (0 == helper.getAdapterPosition()) {
                line2.setVisibility(View.VISIBLE);
                line1.setVisibility(View.GONE);
            } else if (getItemCount() - 1 == helper.getAdapterPosition()) {
                line2.setVisibility(View.GONE);
                line1.setVisibility(View.VISIBLE);
            }
            item1.setTextColor(mContext.getResources().getColor(R.color.textColor_999));
            item1.setVisibility(View.GONE);
            line1.setBackgroundColor(mContext.getResources().getColor(R.color.bottom_line));
            line2.setBackgroundColor(mContext.getResources().getColor(R.color.bottom_line));
            imageView.setImageResource(R.drawable.round_4_cc);
            int status = item.getStatus();
            if (status == 1) {
                line1.setBackgroundColor(mContext.getResources().getColor(R.color.color_4d00));
                imageView.setImageResource(R.drawable.icon_transited);
                item1.setText("运输中");
                item1.setVisibility(View.VISIBLE);
            } else if (status == 2) {
                imageView.setImageResource(R.drawable.icon_express);
                line2.setBackgroundColor(mContext.getResources().getColor(R.color.color_4d00));
                item1.setTextColor(mContext.getResources().getColor(R.color.color_333333));
                item1.setText("派送中");
                item1.setVisibility(View.VISIBLE);
            }
        }

    }
}
